import { defineStore } from 'pinia'
import { ref } from 'vue'
 

export const useServerUserStore=defineStore('user-server',()=>{
    console.log('user ``````');
    
    const token=ref('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MzMsInJvbGVJZCI6MywiaWF0IjoxNzQ0NTM3Mjg5LCJleHAiOjE3NDQ2MjM2ODl9.zIAlLJqpCdxbR540od4OmU91vHsiZnPYigQ2OVjk7qw')
    const userInfo=ref({
        id: 33,
        roleId: 3
    })

   
    const setToken=( newToken ) => {
        token.value= newToken
    }

    const removeToken=() => {
        token.value=''
    }
    
    const setUserInfo=( id,roleId ) => {
        userInfo.value.id= id
        userInfo.value.roleId= roleId
    }




    return{
        token,
        userInfo,
        
        setUserInfo,
        setToken,
        removeToken,
    }
},{
    persist: true 
})